package com.lemon.stock.net

import io.reactivex.Observable
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

interface SinaApiService {

    @GET("list={list}")
    fun stock(@Path("list") list: String): Observable<String>

    companion object Factory {
        fun create(): SinaApiService {
            val retrofit = Retrofit.Builder()
                .baseUrl("https://hq.sinajs.cn/")
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                //.addConverterFactory(GsonConverterFactory.create())
                .addConverterFactory(ScalarsConverterFactory.create())
                .build()

            return retrofit.create(SinaApiService::class.java);
        }
    }
}